package chatGUI;

import javax.swing.*;

/**
 * Connection window : it is the first interface with tue user.
 * You can login or quit.
 */
public class ConnectionFrame extends JFrame{
	protected JPanel connectPanel;
	protected JLabel loginLabel;
	protected JButton connectButton;
	protected JButton quitButton;
	protected JTextField pseudoText;
	protected JLabel csLabel;

	/* Les attributs de la fenetre de connexion */
	//The frame

	/*protected JLabel welcome = new JLabel("Welcome !");
	//The panels
	protected JPanel buttonPanel = new JPanel();
	//The layouts
	protected GridLayout gridLogin = new GridLayout(2,1);
	protected FlowLayout flowButton = new FlowLayout(FlowLayout.CENTER);
	//The labels
	JLabel pseudo = new JLabel("Login");
	//The textfield
	JTextField pseudoText = new JTextField(20);
	//The button
	JButton connectButton = new JButton("Sign in");*/

	public ConnectionFrame(){
		initFrame();
	}

	private void initFrame(){	
		{
		}
		//add components to their panel
		//set layouts to the panels
		//this.loginPanel.setLayout(gridLogin);
		//this.buttonPanel.setLayout(flowButton);

		//add panels to general panel
		//add general panel to frame
		//this.setLayout(new BorderLayout());
		//this.add(welcome,BorderLayout.NORTH);


		this.pack();

		//paramétrage de la JFrame
		this.setTitle("Chat System - Connection");
		this.setSize(300, 400);
		this.setLocationRelativeTo(null);
		this.setDefaultCloseOperation(EXIT_ON_CLOSE);
		GroupLayout thisLayout = new GroupLayout((JComponent)getContentPane());
		getContentPane().setLayout(thisLayout);
		this.setVisible(true);	
		{
			connectPanel = new JPanel();
			GroupLayout connectPanelLayout = new GroupLayout((JComponent)connectPanel);
			connectPanel.setLayout(connectPanelLayout);
			connectPanel.setBackground(new java.awt.Color(77,77,77));
			{
				csLabel = new JLabel();
				csLabel.setText("Chat System");
				csLabel.setFont(new java.awt.Font("FreeMono",1,36));
				csLabel.setForeground(new java.awt.Color(213,129,65));
			}
			{
				loginLabel = new JLabel();
				loginLabel.setText("Your login");
				loginLabel.setFont(new java.awt.Font("Andale Mono",1,14));
				loginLabel.setForeground(new java.awt.Color(255,255,255));
			}
			{
				pseudoText = new JTextField();
			}
			{
				quitButton = new JButton();
				quitButton.setText("Quit");
			}
			{
				connectButton = new JButton();
				connectButton.setText("Enter");
			}
			connectPanelLayout.setHorizontalGroup(connectPanelLayout.createSequentialGroup()
					.addContainerGap(20, 20)
					.addGroup(connectPanelLayout.createParallelGroup()
							.addComponent(csLabel, GroupLayout.Alignment.LEADING, 0, 249, Short.MAX_VALUE)
							.addGroup(connectPanelLayout.createSequentialGroup()
									.addGap(28)
									.addGroup(connectPanelLayout.createParallelGroup()
											.addGroup(GroupLayout.Alignment.LEADING, connectPanelLayout.createSequentialGroup()
													.addComponent(loginLabel, GroupLayout.PREFERRED_SIZE, 109, GroupLayout.PREFERRED_SIZE)
													.addGap(0, 71, Short.MAX_VALUE))
													.addGroup(connectPanelLayout.createSequentialGroup()
															.addGap(22)
															.addGroup(connectPanelLayout.createParallelGroup()
																	.addGroup(connectPanelLayout.createSequentialGroup()
																			.addComponent(pseudoText, GroupLayout.PREFERRED_SIZE, 158, GroupLayout.PREFERRED_SIZE)
																			.addGap(0, 0, Short.MAX_VALUE))
																			.addGroup(GroupLayout.Alignment.LEADING, connectPanelLayout.createSequentialGroup()
																					.addGap(0, 0, Short.MAX_VALUE)
																					.addComponent(connectButton, GroupLayout.PREFERRED_SIZE, 72, GroupLayout.PREFERRED_SIZE)
																					.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
																					.addComponent(quitButton, GroupLayout.PREFERRED_SIZE, 72, GroupLayout.PREFERRED_SIZE)
																					.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)))))
																					.addGap(41)))
																					.addContainerGap(21, 21));
			connectPanelLayout.setVerticalGroup(connectPanelLayout.createSequentialGroup()
					.addContainerGap(44, 44)
					.addComponent(csLabel, GroupLayout.PREFERRED_SIZE, 29, GroupLayout.PREFERRED_SIZE)
					.addGap(70)
					.addComponent(loginLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
					.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
					.addComponent(pseudoText, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
					.addGap(25)
					.addGroup(connectPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
							.addComponent(connectButton, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
							.addComponent(quitButton, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
							.addContainerGap(114, 114));
		}
		thisLayout.setVerticalGroup(thisLayout.createSequentialGroup()
				.addComponent(connectPanel, 0, 370, Short.MAX_VALUE));
		thisLayout.setHorizontalGroup(thisLayout.createSequentialGroup()
				.addComponent(connectPanel, GroupLayout.PREFERRED_SIZE, 311, GroupLayout.PREFERRED_SIZE));
	}

}
